
$(function () {

    //1.使用 axios

    axios.defaults.baseUrl = "http://127.0.0.1:8080";
    $("form").submit(function () {
        var data = $(this).serialize();
        axios({
            url: "/api/login",
            method: "post",
            data: data
        }).then(function (res) {
            console.log(res)
            console.log(res.data.token)
            layer.alert(res.data.msg);
            if(res.data.status>=1){
                location.href = "./index.html";
            }
            if (res.data.status) {
                localStorage.setItem("token", res.data.token);
                localStorage.setItem("user", JSON.stringify(res.data.data));
            }
        })

        return false;
    })
})
